﻿namespace WMS6.Services
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    using WMS6.BLL;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.QueryEntity;

    [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall), AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
    public class OutboundService2 : IOutboundService2
    {
        public string ConfirmShippingReviewByOrderID(List<OrdersInfo> orderList, PubParasInfo pubParasInfo)
        {
            try
            {
                OrdersBLL ordersBLL = new OrdersBLL(pubParasInfo);
                return ordersBLL.ConfirmShippingReviewByOrderID(orderList);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public string CreatedWaveByWaveTemplate(string waveTemplateID, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                WaveTemplateBLL waveTemplateBLL = new WaveTemplateBLL(pubParasInfo);
                return waveTemplateBLL.CreatedWaveByWaveTemplate(waveTemplateID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string DeleteLoadDetailInfo(string loadID, List<string> lineID, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                LoadBLL loadBLL = new LoadBLL(pubParasInfo);
                return loadBLL.DeleteLoadDetailInfo(loadID, lineID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string DeleteLoadInfo(List<string> loadID, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                LoadBLL loadBLL = new LoadBLL(pubParasInfo);
                return loadBLL.DeleteLoadInfo(loadID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string DeleteVanning(List<string> vanningID, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                VanningBLL vanningBLL = new VanningBLL(pubParasInfo);
                return vanningBLL.DeleteVanning(vanningID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string DeleteVanningContainer(string vanningID, List<string> containerID, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                VanningBLL vanningBLL = new VanningBLL(pubParasInfo);
                return vanningBLL.DeleteVanningContainer(vanningID, containerID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string DeleteWaveFlowDetailInfo(List<string> waveFlowID, List<string> lineID, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                WaveFlowDetailBLL waveFlowDetailBLL = new WaveFlowDetailBLL(pubParasInfo);
                return waveFlowDetailBLL.DeleteWaveFlowInfo(waveFlowID, lineID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string DeleteWaveFlowInfo(List<string> waveFlowID, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                WaveFlowBLL waveFlowBLL = new WaveFlowBLL(pubParasInfo);
                return waveFlowBLL.DeleteWaveFlowInfo(waveFlowID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string DeleteWaveTemplate(List<string> IDS, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new WaveTemplateBLL(pubParasInfo).DeleteWaveTemplate(IDS);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public DataSet GetAllLoad(PubParasInfo pubParasInfo)
        {
            try
            {
                LoadBLL loadBLL = new LoadBLL(pubParasInfo);
                return loadBLL.GetAllLoad();
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public DataSet GetAllWaveFlowDetailInfo(PubParasInfo pubParasInfo)
        {
            try
            {
                WaveFlowDetailBLL waveFlowDetailBLL = new WaveFlowDetailBLL(pubParasInfo);
                return waveFlowDetailBLL.GetAllWaveFlowDetailInfo();
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public DataSet GetAllWaveFlowInfo(PubParasInfo pubParasInfo)
        {
            try
            {
                WaveFlowBLL waveFlowBLL = new WaveFlowBLL(pubParasInfo);
                return waveFlowBLL.GetAllWaveFlowInfo();
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public DataSet GetAllWaveTemplateInfo(PubParasInfo pubParasInfo)
        {
            try
            {
                WaveTemplateBLL waveTemplateBLL = new WaveTemplateBLL(pubParasInfo);
                return waveTemplateBLL.GetAllWaveTemplateInfo();
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public List<OrderDetailInfo> GetBatchOrdersInfoAndDetailListByID(string waveID, string ContainerID, PubParasInfo pubParasInfo)
        {
            List<OrderDetailInfo> ordersDetailList = new List<OrderDetailInfo>();
            try
            {
                WaveBLL waveBLL = new WaveBLL(pubParasInfo);
                return waveBLL.GetBatchOrdersInfoAndDetailListByID(waveID, ContainerID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return ordersDetailList;
        }

        public LoadHeaderInfo GetLoadByID(string loadID, PubParasInfo pubParasInfo)
        {
            try
            {
                LoadBLL loadBLL = new LoadBLL(pubParasInfo);
                return loadBLL.GetLoadByID(loadID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public DataSet GetLoadByQueryEntity(LoadHeaderQueryEntity loadHeaderQueryEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                LoadBLL loadBLL = new LoadBLL(pubParasInfo);
                return loadBLL.GetLoadByQueryEntity(loadHeaderQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public List<OrdersInfo> GetShippingReviewByOrderID(string orderID, string ShippingReviewType, PubParasInfo pubParasInfo)
        {
            try
            {
                OrdersBLL ordersBLL = new OrdersBLL(pubParasInfo);
                return ordersBLL.GetShippingReviewByOrderID(orderID, ShippingReviewType);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public List<string> GetUnPrintShippingPickDetailIDByOrderID(string orderID, PubParasInfo pubParasInfo)
        {
            List<string> result = new List<string>();
            try
            {
                result = new OutboundMgtBLL(pubParasInfo).GetUnPrintShippingPickDetailIDByOrderID(orderID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public VanningInfo GetVanningByID(string vanningID, PubParasInfo pubParasInfo)
        {
            try
            {
                VanningBLL vanningBLL = new VanningBLL(pubParasInfo);
                return vanningBLL.GetVanningByID(vanningID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public List<VanningDetailInfo> GetVanningDetailByID(string vanningID, string containerID, PubParasInfo pubParasInfo)
        {
            List<VanningDetailInfo> vanningDetailList = new List<VanningDetailInfo>();
            try
            {
                VanningBLL vanningBLL = new VanningBLL(pubParasInfo);
                return vanningBLL.GetVanningDetailByID(vanningID, containerID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return vanningDetailList;
        }

        public DataSet GetVanningInfoByQueryEntity(VanningQueryEntity vanningQueryEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                VanningBLL vanningBLL = new VanningBLL(pubParasInfo);
                return vanningBLL.GetVanningInfoByQueryEntity(vanningQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public List<WaveFlowDetailInfo> GetWaveFlowDetailInfoByID(string waveFlowID, PubParasInfo pubParasInfo)
        {
            List<WaveFlowDetailInfo> waveFlowDetailInfoList = new List<WaveFlowDetailInfo>();
            try
            {
                WaveFlowDetailBLL waveFlowDetailBLL = new WaveFlowDetailBLL(pubParasInfo);
                return waveFlowDetailBLL.GetWaveFlowDetailInfoByID(waveFlowID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return waveFlowDetailInfoList;
        }

        public WaveFlowDetailInfo GetWaveFlowDetailInfoByIDLineID(string waveFlowID, string lineID, PubParasInfo pubParasInfo)
        {
            try
            {
                WaveFlowDetailBLL waveFlowDetailBLL = new WaveFlowDetailBLL(pubParasInfo);
                return waveFlowDetailBLL.GetWaveFlowDetailInfoByIDLineID(waveFlowID, lineID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public WaveFlowInfo GetWaveFlowInfoByID(string waveFlowID, PubParasInfo pubParasInfo)
        {
            try
            {
                WaveFlowBLL waveFlowBLL = new WaveFlowBLL(pubParasInfo);
                return waveFlowBLL.GetWaveFlowInfoByID(waveFlowID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public DataSet GetWaveFlowInfoByQueryEntity(WaveFlowQueryEntity waveFlowQueryEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                WaveFlowBLL waveFlowBLL = new WaveFlowBLL(pubParasInfo);
                return waveFlowBLL.GetWaveFlowInfoByQueryEntity(waveFlowQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public WaveTemplateInfo GetWaveTemplateByID(string id, PubParasInfo pubParasInfo)
        {
            try
            {
                WaveTemplateBLL waveTemplateBLL = new WaveTemplateBLL(pubParasInfo);
                return waveTemplateBLL.GetWaveTemplateByID(id);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public DataSet GetWaveTemplateByQueryList(WaveTemplateQueryEntity waveQuery, PubParasInfo pubParasInfo)
        {
            try
            {
                WaveTemplateBLL waveTemplateBLL = new WaveTemplateBLL(pubParasInfo);
                return waveTemplateBLL.GetWaveTemplateByQueryList(waveQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public string InsertLoadDetailInfo(string orderID, string loadID, string lineID, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                LoadBLL loadBLL = new LoadBLL(pubParasInfo);
                return loadBLL.InsertLoadDetailInfo(orderID, loadID, lineID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string InsertLoadInfo(LoadHeaderInfo loadHeaderInfo, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                LoadBLL loadBLL = new LoadBLL(pubParasInfo);
                return loadBLL.InsertLoadInfo(loadHeaderInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string InsertVanning(VanningInfo vanningInfo, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                VanningBLL vanningBLL = new VanningBLL(pubParasInfo);
                return vanningBLL.InsertVanning(vanningInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string InsertVanningDetail(List<VanningDetailInfo> vanningDetailList, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                VanningBLL vanningBLL = new VanningBLL(pubParasInfo);
                return vanningBLL.InsertVanningDetail(vanningDetailList);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string InsertWaveFlowDetailInfo(WaveFlowDetailInfo waveFlowDetailInfo, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                WaveFlowDetailBLL waveFlowDetailBLL = new WaveFlowDetailBLL(pubParasInfo);
                return waveFlowDetailBLL.InsertWaveFlowDetailInfo(waveFlowDetailInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string InsertWaveFlowInfo(WaveFlowInfo waveFlowInfo, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                WaveFlowBLL waveFlowBLL = new WaveFlowBLL(pubParasInfo);
                return waveFlowBLL.InsertWaveFlowInfo(waveFlowInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string InsertWaveTemplate(WaveTemplateInfo obj, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new WaveTemplateBLL(pubParasInfo).InsertWaveTemplate(obj);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public List<OrderDetailInfo> PreviewWaveByWaveTemplate(string waveTemplateID, PubParasInfo pubParasInfo)
        {
            try
            {
                WaveTemplateBLL waveTemplateBLL = new WaveTemplateBLL(pubParasInfo);
                return waveTemplateBLL.PreviewWaveByWaveTemplate(waveTemplateID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public string ShippedByOrderLineQty(string orderID, List<string> orderLineIDs, List<decimal> qtys, string shippDate, string updatedBy, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                OutboundMgtBLL outboundMgtBll = new OutboundMgtBLL(pubParasInfo);
                return outboundMgtBll.ShippedByOrderLineID(orderID, orderLineIDs, qtys, shippDate, updatedBy);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return temp;
        }

        public string ShippingCarriersAssigned(List<string> orderID, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new OutboundMgtBLL(pubParasInfo).ShippingCarriersAssigned(orderID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string UpdateLoadAndOrderStatusByLoadID(string status, string loadID, PubParasInfo pubParasInfo)
        {
            try
            {
                LoadBLL loadBLL = new LoadBLL(pubParasInfo);
                return loadBLL.UpdateLoadAndOrderStatusByLoadID(status, loadID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public string UpdateLoadInfo(LoadHeaderInfo loadHeaderInfo, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                LoadBLL loadBLL = new LoadBLL(pubParasInfo);
                return loadBLL.UpdateLoadInfo(loadHeaderInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string UpdateOrderStatusByOrderID(List<string> orderIDList, string ordersStatus, string operators, DateTime operatingDate, string abnormal, string handling, List<string> lineID, List<decimal> numberLost, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new OrdersBLL(pubParasInfo).UpdateOrderStatusByOrderID(orderIDList, ordersStatus, operators, operatingDate, abnormal, handling, lineID, numberLost);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string UpdateVanning(VanningInfo vanningInfo, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                VanningBLL vanningBLL = new VanningBLL(pubParasInfo);
                return vanningBLL.UpdateVanning(vanningInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string UpdateVanningDetail(List<VanningDetailInfo> vanningDetailList, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                VanningBLL vanningBLL = new VanningBLL(pubParasInfo);
                return vanningBLL.UpdateVanningDetail(vanningDetailList);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string UpdateWaveFlowDetailInfo(WaveFlowDetailInfo waveFlowDetailInfo, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                WaveFlowDetailBLL waveFlowDetailBLL = new WaveFlowDetailBLL(pubParasInfo);
                return waveFlowDetailBLL.UpdateWaveFlowDetailInfo(waveFlowDetailInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string UpdateWaveFlowInfo(WaveFlowInfo waveFlowInfo, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                WaveFlowBLL waveFlowBLL = new WaveFlowBLL(pubParasInfo);
                return waveFlowBLL.UpdateWaveFlowInfo(waveFlowInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string UpdateWaveTemplate(WaveTemplateInfo obj, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new WaveTemplateBLL(pubParasInfo).UpdateWaveTemplate(obj);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return result;
        }

        public string waveOrderActions(string waveID, List<string> orderID, List<string> orderLineID, string waveOrderType, string updatedBy, PubParasInfo pubParasInfo)
        {
            try
            {
                OutboundMgtBLL outboundMgtBLL = new OutboundMgtBLL(pubParasInfo);
                return outboundMgtBLL.waveOrderActions(waveID, orderID, orderLineID, waveOrderType, updatedBy);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return null;
        }

        public string WaveReleasePickTasks(List<string> waveID, string userID, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                OutboundMgtBLL outboundMgtBll = new OutboundMgtBLL(pubParasInfo);
                return outboundMgtBll.WaveReleasePickTasks(waveID, userID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "OutboundService2异常");
            }
            return temp;
        }
    }
}

